package fr.lille.inria.adam.lifl.EcoGardeInventory.Utils.sparse;

import android.util.SparseArray;

public class SparseToString {
	public static String toString(SparseArray<?> a) {
		if (a==null) return "null";
		if (a.size() <= 0) return "[]";
		StringBuilder sb = new StringBuilder('[');
		for (int it=0; it<a.size(); it++) {
			Object value = a.valueAt(it);
			sb.append("[key=").append(a.keyAt(it))
			.append(" value=").append((value==null)?"null":value.toString())
			.append("], ");
		}
		sb.delete(sb.length()-2, sb.length());
		sb.append(']');
		return sb.toString();
	}
}
